package com.synface.utils.Logs;

import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

public class MyToast
{
  private Context mContext;
  private Handler mHandler;
  private Toast myToast;
  private Runnable toastRunnable = new Runnable()
  {
    public void run()
    {
      MyToast.this.myToast.show();
    }
  };

  public MyToast(Context context)
  {
    this.mContext = context;
    this.mHandler = new Handler(this.mContext.getMainLooper());
    this.myToast = Toast.makeText(this.mContext, "", 1);
  }

  public void showToast(String string) {
    if (string == null)
      string = "Toast null";
    if (this.myToast == null) {
      this.myToast = Toast.makeText(this.mContext, string, 1);
    }
    this.myToast.setText(string);
    this.mHandler.post(this.toastRunnable);
  }

  public void cancel()
  {
    this.mHandler.removeCallbacks(this.toastRunnable);
    this.myToast.cancel();
  }
}